SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO



alter  view dbo.v_tb_paymentB
as   
  select m.bstate,  
	 isnull(d.relationbtype,0) as relationbtype,isnull(d.relationbid,0) as relationbid,isnull(sum(d.amount),0) as amount,  
	 0 as lcamount  
	from dbo.tb_payment m 
	left join (select row_number() over (partition by bid order by bno) as bdtlno,* from tb_paymentdtl) d on m.bid = d.bid  
	group by m.bstate,d.relationbtype,d.relationbid  


GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

